//
//  LSMainButtonView.m
//  LaSaCivilAffairsDepartment
//
//  Created by 聂志康 on 2018/12/18.
//  Copyright © 2018 wpkj. All rights reserved.
//

#import "LSMainButtonView.h"

@interface LSMainButtonView ()
@property (nonatomic, strong) UIImageView *buttonImageView;
@property (nonatomic, strong) UILabel *buttonTitleLabel;
@end

@implementation LSMainButtonView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.buttonImageView];
        [self addSubview:self.buttonTitleLabel];
    }
    return self;
}

- (void)setButtonTitle:(NSString *)buttonTitle {
    _buttonTitle = buttonTitle;
    self.buttonTitleLabel.text = buttonTitle;
}

- (void)setButtonImageName:(NSString *)buttonImageName {
    _buttonImageName = buttonImageName;
    self.buttonImageView.image = [UIImage imageNamed:buttonImageName];
}

- (UIImageView *)buttonImageView {
    if (!_buttonImageView) {
        _buttonImageView = [[UIImageView alloc] initWithFrame:CGRectMake(((ScreenWidth-8)/3-73)/2, 20, 73, 73)];
        _buttonImageView.layer.cornerRadius = 73/2;
        _buttonImageView.layer.masksToBounds = true;
    }
    return _buttonImageView;
}

- (UILabel *)buttonTitleLabel {
    if (!_buttonTitleLabel) {
        _buttonTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 20+73+15, self.frame.size.width, 15)];
        _buttonTitleLabel.textColor = hexColor(333333);
        _buttonTitleLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:15];
        _buttonTitleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _buttonTitleLabel;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
